function first = nonnan_first(A)
% This code returns the positions of the first and last non-nan
% observations
    if size(A , 2) > 1
        error('Must be column')
    end
    first = find(~isnan(A), 1);
end